import { GetBlob } from 'services'
export const download = (url: string, params: any) => {
    GetBlob(url, params).then((res) => {
        const fileName = window.decodeURI(res.headers['content-disposition'].split('\'\'')[1])
        const blob = new Blob([res.data], { type: res.headers['content-type'] })
        const link = document.createElement('a')
        const event = document.createEvent('HTMLEvents')
        event.initEvent('click', false, false)
        link.href = window.URL.createObjectURL(blob)
        link.setAttribute('download', fileName)
        link.style.display = 'none'
        document.body.appendChild(link)
        link.click()
        document.body.removeChild(link)
        window.URL.revokeObjectURL(link.href)
    })
}